package com.leyou.item.comtroller;

import com.leyou.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName ItemController.java
 * @Description TODO
 * @createTime 2020年04月29日 15:48:00
 */
@RestController
public class ItemController {
    @Autowired
    private ItemService itemService;

    /**
     * HttpStatus.OK 表示查询操作成功
     * HttpStatus.CREATED 表示添加操作成功
     * HttpStatus.NO_CONTENT 修改或者删除成功
     * @param id
     * @return
     */
    @PostMapping("/save")
    public ResponseEntity<Long> saveItem(@RequestParam("id") Long id){
        Long result = itemService.saveItem(id);
        return ResponseEntity.status(HttpStatus.CREATED)//用来指定返回结果的状态码
                .body(result);//返回的数据
    }

    // @PostMapping("/save")
    // public Long saveItem(@RequestParam("id") Long id){
    //     return itemService.saveItem(id);
    // }

}
